import { SettingsModel } from "server/models/Settings";

export default defineEventHandler(async (event) => {
  try {
    const body = await readBody(event);

    if (!body || Object.keys(body).length === 0) {
      return {
        success: false,
        message: "请求数据不能为空",
        data: null,
      };
    }

    // 批量更新简历设置
    const success = await SettingsModel.batchUpdate(body, "resume");

    if (success) {
      return {
        success: true,
        message: "简历信息保存成功",
        data: body,
      };
    } else {
      throw new Error("保存简历信息失败");
    }
  } catch (error: any) {
    console.error("保存简历信息失败:", error);

    return {
      success: false,
      message: `保存简历信息失败: ${error.message}`,
      data: null,
    };
  }
});
